home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Graphismes / Bitmap / NIH Image 1.59 / Macros / Gel Plotting Macros (old) < prev    next >
Text File  |  1994-01-11  |  5KB  |  181 lines

  1. var  {Global variables}
  2.   RoiLeft,RoiTop,RoiWidth,RoiHeight,PlotColor:integer;
  3.   GelWidth,GelHeight,MaxPlotWindowHeight,NeededSize:integer;
  4.   GelWindow,PlotWindow,PlotLeft,PlotTop,PlotWidth,PlotHeight:integer;
  5.   hMargin,vMargin,nLanes,SavePlotTop,PlotWindowSize:integer;
  6.   LeftMargin,TopMargin,RightMargin,BottomMargin:integer;
  7.   FirstBackgroundPlot:boolean;
  8.  
  9. macro 'Setup to Plot Gel [Z]';
  10. {This macro, along with the Plot Lane macro, is used to generate profile}
  11. {plots of the lanes in a one dimensional electoproretic gel.}
  12. var
  13.   nPixels,mean,mode,min,max:real;
  14.   PlotWinHeight:integer;
  15. begin
  16.   RequiresVersion(1.53);
  17.   PlotHeight:=175;
  18.   PlotWidth:=500;
  19.   MaxPlotWindowHeight:=720;
  20.   GetRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight);
  21.   if RoiWidth=0 then begin
  22.     PutMessage('The Setup macro expects the Gel to be displayed and the first lane outlined.');
  23.     exit;
  24.   end;
  25.   if PlotWidth<RoiWidth then PlotWidth:=RoiWidth;
  26.   if PlotWidth>(2*RoiWidth) then PlotWidth:=2*RoiWidth;
  27.   if RoiHeight>RoiWidth then begin
  28.     PutMessage('Lanes must be horizontal.');
  29.     exit;
  30.   end;
  31.   if nPics<>1 then begin
  32.     PutMessage('The window containing the gel should be the only image window open.');
  33.     exit;
  34.   end;
  35.   nLanes:=GetNumber('Number of lanes?',1);
  36.   GetPicSize(GelWidth,GelHeight);
  37.   MakeRoi(RoiLeft,RoiTop,RoiWidth,GelHeight-RoiTop);
  38.   Measure;
  39.   GetResults(nPixels,mean,mode,min,max);
  40.   hMargin:=5;
  41.   vMargin:=5;
  42.   LeftMargin:=38; {Changed in v1.53}
  43.   TopMargin:=10;
  44.   RightMargin:=20;
  45.   BottomMargin:=20;
  46.   PlotLeft:=hMargin-LeftMargin;
  47.   PlotTop:=vMargin-TopMargin;
  48.   SavePlotTop:=PlotTop;
  49.   PlotWinHeight:=nLanes*PlotHeight+2*vMargin;
  50.   if PlotWinHeight>MaxPlotWindowHeight then begin
  51.     PlotWinHeight:=MaxPlotWindowHeight;
  52.     PlotHeight:=(PlotWinHeight-2*vMargin)/nLanes;
  53.   end;
  54.   PlotWindowSize:=(PlotWidth+2*hMargin)*PlotWinHeight;
  55.   if PlotWindowSize>UndoBufferSize then begin
  56.     NeededSize:=(PlotWindowSize+0.05*PlotWindowSize) div 1024;
  57.     PutMessage('Use Preferences(Options Menu) to increase the Undo buffer size to at least ',NeededSize:1,'K.');
  58.     KillRoi;
  59.     exit;
  60.   end;
  61.   SetNewSize(PlotWidth+2*hMargin,PlotWinHeight);
  62.   SetForegroundColor(255);
  63.   SetBackgroundColor(0);
  64.   MakeNewWindow('Plots');
  65.   SetPlotSize(PlotWidth,PlotHeight);
  66.   min:=min-1;
  67.   if min<0 then min:=0;
  68.   max:=max+5;
  69.   if max>255 then max:=255;
  70.   SetPlotScale(cValue(min),cValue(max));
  71.   SetPlotLabels(false);
  72.   GelWindow:=1;
  73.   PlotWindow:=2;
  74.   SelectPic(GelWindow);
  75.   MakeRoi(RoiLeft,RoiTop,RoiWidth,RoiHeight);
  76.   FirstBackgroundPlot:=true;
  77.   PlotColor:=1;
  78.   ResetCounter;
  79.   SetOptions('Area');
  80.   WandAutoMeasure(true);
  81.   AdjustAreas(true);
  82.   LabelParticles(false);
  83.   IncludeInteriorHoles(true);
  84.   SetFontSize(9);
  85.   SetText('Centered');
  86.   SetLineWidth(1);
  87. end;
  88.  
  89.  
  90. macro 'Plot Lane [P]';
  91. var
  92.   left,top,width,height:integer;
  93.   GelNotCalibrated:boolean;
  94. begin
  95.   if (GelWidth=0) or (nPics=1) then begin
  96.     PutMessage
  97.       ('Before using the Plot Lane macro you must first use the Setup macro.');
  98.     Exit;
  99.   end;
  100.   GelNotCalibrated:=not Calibrated;
  101.   GetRoi(left,top,width,height);
  102.   MakeRoi(RoiLeft,top,RoiWidth,RoiHeight);
  103.   SetOption;
  104.   ColumnAveragePlot;
  105.   Copy;
  106.   SelectPic(PlotWindow);
  107.   MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
  108.           PlotHeight+TopMargin+BottomMargin);
  109.   Paste;
  110.   DoOr;
  111.   if GelNotCalibrated and (PlotTop=SavePlotTop) then begin
  112.     SetText('Left Justified; With Background');
  113.     MoveTo(PlotLeft+LeftMargin+6,PlotTop+TopMargin+1);
  114.     SetFontSize(12);
  115.     Write('Uncalibrated');
  116.     SetFontSize(9);
  117.     SetText('Centered; No Background');
  118.   end;
  119.   PlotTop:=PlotTop+PlotHeight-1;
  120.   SelectPic(GelWindow);
  121. end;
  122.  
  123.  
  124. macro 'Plot Background Lane [B]';
  125. {Plot all lanes before plotting backgrounds. Unlike the lane plotting macro,}
  126. {you are allowed to change the height of the selection.}
  127. var
  128.   left,top,width,height:integer;
  129. begin
  130.   if (GelWidth=0) or (nPics=1) then begin
  131.     PutMessage('Use Setup first.');
  132.     Exit;
  133.   end;
  134.   GetRoi(left,top,width,height);
  135.   MakeRoi(RoiLeft,top,RoiWidth,height);
  136.   ColumnAveragePlot;
  137.   Copy;
  138.   SelectPic(PlotWindow);
  139.   if FirstBackgroundPlot then begin
  140.     FirstBackgroundPlot:=false;
  141.     PlotTop:=SavePlotTop;
  142.   end;
  143.   MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
  144.           PlotHeight+TopMargin+BottomMargin);
  145.   Paste;
  146.   DoOr;
  147.   PlotTop:=PlotTop+PlotHeight-1;
  148.   SelectPic(GelWindow);
  149. end;
  150.  
  151.  
  152. macro 'Plot Overlayed [O]';
  153. var
  154.   left,top,width,height:integer;
  155. begin
  156.   if (GelWidth=0) or (nPics=1) then begin
  157.     PutMessage('Use Setup first.');
  158.     Exit;
  159.   end;
  160.   if PlotColor=1 then SetPalette('256 Color Spectrum');
  161.   GetRoi(left,top,width,height);
  162.   MakeRoi(RoiLeft,top,RoiWidth,height);
  163.   ColumnAveragePlot;
  164.   Copy;
  165.   SelectPic(PlotWindow);
  166.   if PlotColor=1 then SetPalette('256 Color Spectrum');
  167.   SetForegroundColor(PlotColor);
  168.   PlotTop:=PlotTop-PlotHeight+1;
  169.   if PlotTop<SavePlotTop then PlotTop:=SavePlotTop;
  170.   MakeRoi(PlotLeft,PlotTop,PlotWidth+LeftMargin+RightMargin,
  171.           PlotHeight+TopMargin+BottomMargin);
  172.   Paste;
  173.   DoOr;
  174.   PlotTop:=PlotTop+PlotHeight-1;
  175.   SelectPic(GelWindow);
  176.   PlotColor:=(PlotColor+74) mod 254;
  177. end;
  178.  
  179.  
  180.  
  181.